package com.ny.demo526;

import java.util.Set;
import java.util.HashSet;
import java.util.Scanner;

public class ViewMain {
    public static void main(String[] args) {
        boolean flag = true;
        TestSet testList = new TestSet();
        Set<Emp> set = new HashSet<>();

        while (flag) {
            testList.menu();
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();

            switch (n) {
                case 0:
                    System.out.println("退出系统");
                    flag = false;
                    break;

                case 1:
                    System.out.println("添加员工界面");
                    System.out.println("请输入员工信息");
                    System.out.print("请输入员工编号：");
                    String number = scanner.next();
                    System.out.print("请输入员工姓名：");
                    String name = scanner.next();
                    System.out.print("请输入员工年龄：");
                    int age = scanner.nextInt();

                    Emp emp = new Emp(number, name, age);
                    testList.addEmp(set, emp);
                    System.out.println("当前员工列表：" + set);
                    break;
                case 2:
                    System.out.println("来到查询所有员工信息的界面");
                    testList.findAllEmp(set);
                    break;
                case 3:
                    System.out.println("来到根据查询所有员工信息的界面");
                    System.out.println("请输入员工的姓名");
                    String findName = scanner.next();
                    testList.findEmpName(set, findName);
                    break;
                case 4:
                    System.out.println("来到根据员工编号删除员工信息界面");
                    System.out.println("请输入员工的工号");
                    String findNumber = scanner.next();
                    testList.deleteEmpNumber(set, findNumber);
                    break;
                case 5:
                    System.out.println("来到根据员工编号查询员工信息界面");
                    System.out.println("请输入员工的工号");
                    String findEmpNumber = scanner.next();
                    testList.findEmpNumber(set, findEmpNumber);
                    break;
                case 6:
                    System.out.println("来到根据员工编号修改员工年龄界面");
                    System.out.println("请输入需要修改的员工工号");
                    String updateEmpNumber = scanner.next();
                    Emp empToUpdate = testList.findEmpNumber(set, updateEmpNumber);
                    System.out.println("请输入你需要修改的年龄为:");
                    int updateAge = scanner.nextInt();
                    empToUpdate.setAge(updateAge);
                    testList.updateEmpAge(set, empToUpdate);
                    System.out.println(set);
                    break;
            }
        }
    }
}